﻿using System;
using System.ServiceModel.Syndication;
using Jacobi.Seesmic.FeedReader.Utilities;

namespace Jacobi.Seesmic.FeedReader.Model
{
    /// <summary>
    /// Specialized <see cref="FeedSource"/> for an Rss 2.0 feed.
    /// </summary>
    internal sealed class Rss20FeedSource : FeedSource
    {
        /// <summary>
        /// Constructs a new instance on the specified <paramref name="feedInfo"/>.
        /// </summary>
        /// <param name="feedInfo">Must not be null.</param>
        internal Rss20FeedSource(FeedInfo feedInfo)
            : base(feedInfo.Url)
        {
            feedInfo.ThrowIfArgumentIsNull("feedInfo");

            if (feedInfo.FeedType != SyndicationVersions.Rss20)
                throw new ArgumentException("Invalid feed type for Rss 2.0 Feed Source.");
        }

        /// <summary>
        /// Returns a new instance of the <see cref="Rss20FeedFormatter"/>.
        /// </summary>
        /// <returns>Never returns null.</returns>
        protected override SyndicationFeedFormatter CreateFeedFormatter()
        {
            return new Rss20FeedFormatter<TimelineFeed>();
        }
    }
}